/**
* GrayToRGB.v
* 8-bit grayscale to color converter.
* Converts from 8-bit grayscale to max saturation half max luminance colors:
* 0~15 corresponds to black
* 16~55 corresponds to red to yellow range
* 56~95 corresponds to yellow to green range
* 96~135 corresponds to green to blue range
* 136~175 corresponds to blue to teal range
* 176~215 corresponds to teal to purple range
* 216~255 corresponds to purple to red range
*
* Written by Peter Kung and Jsoon Kim
*/

module GrayToRGB(
	iGray,
	oR,
	oG,
	oB);

	input [7:0] iGray; // 8-bit grayscale value
	output [7:0] oR; // 8-bit red value
	output [7:0] oG; // 8-bit blue value
	output [7:0] oB; // 8-bit green value
	
	//Compute red component of output color
	assign oR = (((iGray)-(oG>>1)-(oG>>4)-(oB>>3))<<2);
	
	//Compute green component of output color
	assign oG = (((iGray)-(oR>>2)-(oR>>4)-(oB>>3))<<1);

	
	//Compute blue component of output color
	assign oB = (((iGray)-(oG>>1)-(oG>>4)-(oR>>2)-(oR>>4))<<3);
endmodule
